﻿#region

using Microsoft.AspNetCore.Http;
using Vin.Tool.Domain.ExceptionModel;

#endregion

namespace Vin.Tool.Core.AssertCategory;

public class EmptyTool
{
    public static void CheckIsNullOrEmpty(string? value, string msg,
        int code = StatusCodes.Status500InternalServerError)
    {
        if (value.IsNullOrEmpty()) throw new ErrorException(code, msg);
    }

    public static void CheckIsNullOrEmpty(object? value, string msg,
        int code = StatusCodes.Status500InternalServerError)
    {
        if (value is null) throw new ErrorException(code, msg);
    }

    public static void CheckIsNullOrEmpty(Guid? value, string msg,
        int code = StatusCodes.Status500InternalServerError)
    {
        if (value is null || value == Guid.Empty) throw new ErrorException(code, msg);
    }

    public static void CheckIsNullOrEmpty(Guid value, string msg,
        int code = StatusCodes.Status500InternalServerError)
    {
        if (value == Guid.Empty) throw new ErrorException(code, msg);
    }

    public static void CheckIsNullOrEmpty(DateTime? value, string msg,
        int code = StatusCodes.Status500InternalServerError)
    {
        if (value is null || value == DateTime.MinValue) throw new ErrorException(code, msg);
    }

    public static void CheckIsNullOrEmpty(DateTime value, string msg,
        int code = StatusCodes.Status500InternalServerError)
    {
        if (value == DateTime.MinValue) throw new ErrorException(code, msg);
    }

    public static void CheckIsNullOrZero(long? value, string msg,
        int code = StatusCodes.Status500InternalServerError)
    {
        if (value is null or 0) throw new ErrorException(code, msg);
    }
    
    public static void CheckIsNullOrZero(decimal? value, string msg,
        int code = StatusCodes.Status500InternalServerError)
    {
        if (value is null or 0) throw new ErrorException(code, msg);
    }

    public static void CheckIsNullOrZero(int? value, string msg,
        int code = StatusCodes.Status500InternalServerError)
    {
        if (value is null or 0) throw new ErrorException(code, msg);
    }

    public static void CheckIsNullOrZero(double? value, string msg,
        int code = StatusCodes.Status500InternalServerError)
    {
        if (value is null or 0) throw new ErrorException(code, msg);
    }

    public static void CheckIsNull(object? value, string msg,
        int code = StatusCodes.Status500InternalServerError)
    {
        if (value is null) throw new ErrorException(code, msg);
    }

    public static void CheckArrayIsNullOrEmpty<T>(List<T>? value, string msg,
        int code = StatusCodes.Status500InternalServerError)
    {
        if (value is null || value.Count == 0) throw new ErrorException(code, msg);
    }
}